/*
 * Copyright (C) 2013 Chen Hui <calmer91@gmail.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.harmonyos.fishbun.slice;

import com.harmonyos.fishbun.ResourceTable;
import com.sangcomz.fishbun.util.CommonToolbar;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.aafwk.content.Operation;
import ohos.agp.colors.ColorConverter;
import ohos.agp.colors.RgbColor;
import ohos.agp.components.Component;
import ohos.agp.utils.Color;

public class MainAbilitySlice extends AbilitySlice {
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);

        initListener();
    }

    private void initListener() {
        CommonToolbar toolbar = (CommonToolbar) findComponentById(ResourceTable.Id_toolbar);
        toolbar.setTitle("FishBun", Color.BLACK.getValue());

        findComponentById(ResourceTable.Id_btn_with_activity_basic).setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                Intent intent = new Intent();
                Operation operation = new Intent.OperationBuilder()
                        .withDeviceId("")
                        .withBundleName("com.harmonyos.fishbun")
                        .withAbilityName("com.harmonyos.fishbun.WithActivityAbility")
                        .build();
                intent.setOperation(operation);
                intent.setParam("mode",0);
                startAbility(intent);
            }
        });

        findComponentById(ResourceTable.Id_btn_with_activity_dark).setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                Intent intent = new Intent();
                Operation operation = new Intent.OperationBuilder()
                        .withDeviceId("")
                        .withBundleName("com.harmonyos.fishbun")
                        .withAbilityName("com.harmonyos.fishbun.WithActivityAbility")
                        .build();
                intent.setOperation(operation);
                intent.setParam("mode",1);
                startAbility(intent);
            }
        });

        findComponentById(ResourceTable.Id_btn_with_activity_light).setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                Intent intent = new Intent();
                Operation operation = new Intent.OperationBuilder()
                        .withDeviceId("")
                        .withBundleName("com.harmonyos.fishbun")
                        .withAbilityName("com.harmonyos.fishbun.WithActivityAbility")
                        .build();
                intent.setOperation(operation);
                intent.setParam("mode",2);
                startAbility(intent);
            }
        });

//        findComponentById(ResourceTable.Id_btn_with_Fragment).setClickedListener(new Component.ClickedListener() {
//            @Override
//            public void onClick(Component component) {
//                Intent intent = new Intent();
//                Operation operation = new Intent.OperationBuilder()
//                        .withDeviceId("")
//                        .withBundleName("com.harmonyos.fishbun")
//                        .withAbilityName("com.harmonyos.fishbun.SubAbility")
//                        .build();
//                intent.setOperation(operation);
//                startAbility(intent);
//            }
//        });
    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
